﻿using System.Globalization;
using Lunar;

namespace DesktopToy.Core.Common;

public static class Utils
{
    public static string HttpGet(string url)
    {
        using var client = new HttpClient();
        var response = client.GetAsync(url).Result;
        response.EnsureSuccessStatusCode(); // 确保请求成功
        return response.Content.ReadAsStringAsync().Result;
    }


    /// <summary>
    /// 获取农历
    /// </summary>
    public static string GetLunarDate(DateTime time)
    {
        var solar = new Solar(time.Year, time.Month, time.Day);
        var lunar = solar.Lunar;
        return $"{lunar.MonthInChinese}月{lunar.DayInChinese}";
    }
}